﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<ChoViet.CMS.ViewModels.DistrictViewModel>" %>

<%@ import Namespace="ChoViet.Lib.Helpers" %>
<%@ Import Namespace="ChoViet.Lib.Paging" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Quận huyện
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<%if (ViewData["MessageInfo"] == null)
      { %>
    <form action="/Districts/IndexCms" method="post" name="adminForm">
    <table width="100%">
        <tr>
            <td align="left">
                Tìm nhanh
                <%= Html.TextBox("Keyword", Model.Keyword) %>
                <%= Html.ActionImageJS("Tìm kiếm", "icon-32-search.png", "document.adminForm.submit();", false)%>
            </td>
            <td align="right"><%=Html.DropDownList("CityID", new SelectList(Model.Cities , "ID", "Name", Model.currentCity).ToList(), "-- Chọn tỉnh thành --", new { onchange = "document.adminForm.submit();" })%></td>
        </tr>
        
    </table>
    <table width="100%" class="adminlist">
        <thead>
            <tr>
                <th width="10" align="right">
                    STT
                </th>
                <th width="30">
                </th>
                <th width="30">
                </th>
                <th>
                    <%= Html.Sort("Quận huyện", "Name", ViewData["orderDir"].ToString(), ViewData["order"].ToString())%>
                </th>
                <th style="width: 200px">
                    Thuộc tỉnh thành
                </th>
                <th style="width: 150px">
                    <%= Html.Sort("Tên viết tắt", "ShortName", ViewData["orderDir"].ToString(), ViewData["order"].ToString())%>
                </th>
                <th style="width: 40px">
                    <%=Html.Sort("ID","ID", ViewData["orderDir"].ToString(), ViewData["order"].ToString()) %>
                </th>
            </tr>
        </thead>
        <tbody>
            <% 
                int i = 0;
                foreach (var item in Model.Districts)
                {
                    i++;
            %>
            <tr>
                <td align="right">
                    <%= i.ToString() %>
                </td>
                <td align="center">
                    <%= Html.ActionImage("Sửa", "icon-24-edit.png", "Districts", "EditCms", new Dictionary<string, object>() { { "id", item.ID } })%>
                </td>
                <td align="center">
                    <%= Html.ActionImage("Xóa", "icon-24-delete.png", "Districts", "DeleteCms", new Dictionary<string, object>() { { "id", item.ID } })%>
                </td>
                <td>
                    
                    <%= Html.ActionLink(item.Name, "DetailsCms", new { item.ID })%>
                </td>
                <td>
                    <%= Html.Encode(item.City.Name) %>
                </td>
                <td>
                    <%= Html.Encode(item.ShortName) %>
                </td>
                <td>
                    <%=Html.Encode(item.ID) %>
                </td>
            </tr>
            <% } %>
        </tbody>
    </table>
    <%= Html.Hidden("order")%>
    <%= Html.Hidden("orderDir")%>
    <table width="100%">
        <tr>
            <td align="center">
                <div class="pager">
                    <label>
                        Hiển thị #</label>
                    <%
                        int[] pageSizeList = { 1, 5, 10, 15, 20, 25, 50, 100 };
                    %>
                    <%= Html.DropDownList("PageSize", new SelectList(pageSizeList, Model.Districts.PageSize), new { onchange = "document.adminForm.submit();" })%>
                    <%= Html.Pager(Model.Districts.PageSize, Model.Districts.PageNumber, Model.Districts.TotalItemCount)%>
                </div>
            </td>
        </tr>
    </table>
    </form>
    <% } %>

</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="Toolbar" runat="server">
<td>
    <%= Html.Toolbar("Thêm mới", "/Districts/CreateCms", "new")%>
</td>
</asp:Content>

<asp:Content ID="Content4" ContentPlaceHolderID="Header" runat="server">
Danh sách các quận huyện
</asp:Content>

<asp:Content ID="Content5" ContentPlaceHolderID="Message" runat="server">
<%= ViewData["MessageInfo"] != null ? "<p class='perror'>" + Html.Encode(ViewData["MessageInfo"]) + "</p>" : string.Empty %>
</asp:Content>
